# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=display-switch
pkgver=1.2.0
pkgrel=3
pkgdesc="utility for switching displays over DDC/CI on USB disconnect/connect events"
url="https://github.com/haimgel/display-switch"
arch="all"
license="MIT"
makedepends="cargo eudev-dev libusb-dev cargo-auditable"
install="$pkgname.pre-install"
options="net"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/haimgel/display-switch/archive/$pkgver.tar.gz
	50-i2c.rules
	"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/display_switch -t "$pkgdir"/usr/bin/

	install -Dm644 "$srcdir"/50-i2c.rules \
		"$pkgdir"/lib/udev/rules.d/50-i2c.rules
}

sha512sums="
243fd8fbfb99a7221b78d8458e268dec1dbeaecdb2035d5ad569cf2461ae0eb2c12092ea2132ef4a46b13d9c235475bc1075bf80e6accd3059a97d5c7a04afe2  display-switch-1.2.0.tar.gz
b2c9d0bf35b75f4b52f9db9e243912d356e224afac55348c9702349b74d603d3c659b22f808e59f2e8e45d605c8c244d7c07484186a31e7a3fe3ca72a1715e1e  50-i2c.rules
"
